|
18 | 18 | _nested_replace_type,
|
19 | 19 | define_python_object_encoder,
|
20 | 20 | UnpicklableObject,
|
21 |
| - as_python_object |
| 21 | + as_python_object, |
| 22 | + enforce_reproducibility, |
22 | 23 | )
|
23 | 24 |
|
24 | 25 |
|
@@ -454,5 +455,32 @@ def __init__(self):
|
454 | 455 | self.assertEqual(recreated_obj, expected_obj)
|
455 | 456 |
|
456 | 457 |
|
| 458 | +class EnforceReproducibilityTests(TestCase): |
| 459 | + |
| 460 | + def test_saved_reproducibility_data_is_none(self): |
| 461 | + with self.assertRaises(ValueError): |
| 462 | + enforce_reproducibility(None, {}, 'here') |
| 463 | + |
| 464 | + def test_git_url_not_in_saved_reproducibility_data(self): |
| 465 | + with self.assertRaises(ValueError): |
| 466 | + enforce_reproducibility({}, {}, 'here') |
| 467 | + |
| 468 | + def test_git_url_not_in_current_reproducibility_data(self): |
| 469 | + with self.assertRaises(ValueError): |
| 470 | + enforce_reproducibility({'git_url': 'none'}, {}, 'here') |
| 471 | + |
| 472 | + def test_git_urls_disagree(self): |
| 473 | + with self.assertRaises(ValueError): |
| 474 | + enforce_reproducibility({'git_url': 'none'}, {'git_url': 'some'}, 'here') |
| 475 | + |
| 476 | + def test_throw_error_for_saved_uncommitted_changes(self): |
| 477 | + with self.assertRaises(ValueError): |
| 478 | + enforce_reproducibility({'git_url': 'none', 'git_has_uncommitted_changes': True}, {'git_url': 'some'}, 'here') |
| 479 | + |
| 480 | + def test_throw_error_for_uncommitted_changes(self): |
| 481 | + with self.assertRaises(ValueError): |
| 482 | + enforce_reproducibility({'git_url': 'none', 'git_has_uncommitted_changes': False}, {'git_url': 'some', 'git_has_uncommitted_changes': True}, 'here') |
| 483 | + |
| 484 | + |
457 | 485 | if __name__ == '__main__':
|
458 | 486 | unittest.main()
|
0 commit comments