|
1 | 1 | from labelbox import Project, ExternalWorkforce
|
2 | 2 | import os
|
| 3 | +import sys |
3 | 4 |
|
| 5 | +def _get_workforce_id_for_test() -> str: |
| 6 | + # Basic function to provide an organization id for the test |
| 7 | + # org id from https://labelbox.atlassian.net/wiki/spaces/PLT/pages/2110816271/How+to+labelbox-python+SDK+CI+Tests |
| 8 | + current_version = sys.version_info[:2] |
| 9 | + |
| 10 | + if os.environ['LABELBOX_TEST_ENVIRON'] == "staging": |
| 11 | + return "cltp16p2v04dr07ywfgqxf23u" if current_version == (3, 8) else "clum46jsb00jp07z338dh1gvb" |
| 12 | + else: |
| 13 | + return "cltp1fral01dh07009zsng3zs" if current_version == (3, 8) else "ckcz6bubudyfi0855o1dt1g9s" |
| 14 | + |
4 | 15 |
|
5 | 16 | def test_add_external_workforce(project: Project):
|
6 |
| - # org id from https://labelbox.atlassian.net/wiki/spaces/PLT/pages/2110816271/How+to+labelbox-python+SDK+CI+Tests |
7 |
| - workforce_id = "clum46jsb00jp07z338dh1gvb" if os.environ['LABELBOX_TEST_ENVIRON'] == "staging" else "ckcz6bubudyfi0855o1dt1g9s" |
| 17 | + workforce_id = _get_workforce_id_for_test() |
8 | 18 |
|
9 | 19 | external_workforces = project.add_external_workforce(workforce_id)
|
10 | 20 | assert len(external_workforces) == 1
|
11 | 21 | assert isinstance(external_workforces[0], ExternalWorkforce)
|
12 | 22 |
|
13 | 23 |
|
14 | 24 | def test_get_external_workforces(project: Project):
|
| 25 | + workforce_id = _get_workforce_id_for_test() |
| 26 | + |
| 27 | + external_workforces = project.add_external_workforce(workforce_id) |
| 28 | + |
15 | 29 | external_workforces = project.get_external_workforces()
|
16 | 30 | assert len(external_workforces) == 1
|
17 | 31 | assert isinstance(external_workforces[0], ExternalWorkforce)
|
18 | 32 |
|
19 | 33 |
|
20 |
| -def test_remove_external_workforce(project: Project): |
21 |
| - # org id from https://labelbox.atlassian.net/wiki/spaces/PLT/pages/2110816271/How+to+labelbox-python+SDK+CI+Tests |
22 |
| - workforce_id = "clum46jsb00jp07z338dh1gvb" if os.environ['LABELBOX_TEST_ENVIRON'] == "staging" else "ckcz6bubudyfi0855o1dt1g9s" |
| 34 | +def test_remove_external_workforce(project: Project): |
| 35 | + workforce_id = _get_workforce_id_for_test() |
| 36 | + external_workforces = project.add_external_workforce(workforce_id) |
23 | 37 |
|
24 | 38 | external_workforces = project.remove_external_workforce(workforce_id)
|
25 | 39 | assert len(external_workforces) == 0
|
|
0 commit comments