Beispiel #1
0
def test_actor_to_actor_path_01():
    # Actor path, large database, length of 7 (8 actors, 7 movies)
    actor_1 = 1345462
    actor_2 = 89614
    len_expected = 7

    first_result = lab.actor_to_actor_path(db_large, actor_1, actor_2)
    second_result = lab.actor_to_actor_path(db_large, actor_1, actor_2)

    check_valid_path(fset_large, first_result, actor_1, actor_2, len_expected)
    check_valid_path(fset_large, second_result, actor_1, actor_2, len_expected)
Beispiel #2
0
def test_tiny_actor_to_actor_path():
    # Actor path, tiny db, length of 3
    actor_id_1 = 1640
    actor_id_2 = 1532
    expected = [1640, 2876, 1532]
    result = lab.actor_to_actor_path(db_tiny, actor_id_1, actor_id_2)
    assert result == expected
Beispiel #3
0
def test_actor_to_actor_path_08():
    x = 1234567890
    y = 1234567898
    data = raw_db_large[:]
    data.append((x, y, 0))
    p = lab.actor_to_actor_path(lab.transform_data(data), 4724, y)
    assert p is None
Beispiel #4
0
    def test_g(self):
        expected = [4724, 2876, 1640]
        start_id = 4724
        end_id = 1640

        result = lab.actor_to_actor_path(self.data, start_id, end_id)
        self.assertEqual(result, expected)
Beispiel #5
0
 def test_21(self):
     x = 1234567890
     y = 1234567898
     data = self.db_large[:]
     data.append((x, y, 0))
     p = lab.actor_to_actor_path(data, 4724, y)
     self.assertEqual(p, None)
Beispiel #6
0
 def test_17(self):
     # Bacon path, large database, does not exist
     actor_1 = 43011
     actor_2 = 1204555
     expected = None
     result = lab.actor_to_actor_path(self.db_large, actor_1, actor_2)
     self.assertEqual(result, expected)
Beispiel #7
0
def test_actor_to_actor_path_06():
    # actor path that exists
    e = [184581, 27111, 11086, 170882]
    x = e[0]
    y = e[-1]
    p = lab.actor_to_actor_path(db_large, x, y)
    check_valid_path(raw_db_large, p, x, y, len(e) - 1)
Beispiel #8
0
def test_actor_to_actor_path_04():
    # Bacon path, large database, does not exist
    actor_1 = 43011
    actor_2 = 1204555
    result = lab.actor_to_actor_path(db_large, actor_1, actor_2)

    assert result is None
Beispiel #9
0
def test_actor_to_actor_path_02():
    # Actor path, large database, length of 4 (5 actors, 4 movies)
    actor_1 = 100414
    actor_2 = 57082
    len_expected = 4

    result = lab.actor_to_actor_path(db_large, actor_1, actor_2)
    check_valid_path(raw_db_large, result, actor_1, actor_2, len_expected)
Beispiel #10
0
def test_actor_to_actor_path_tiny():
    # Actor path, Tiny database 3 actors, 2
    actor_1 = 1640
    actor_2 = 1532
    len_expected = 2

    result = lab.actor_to_actor_path(db_tiny, actor_1, actor_2)
    check_valid_path(fset_tiny, result, actor_1, actor_2, len_expected)
Beispiel #11
0
def test_actor_to_actor_path_05():
    # actor path that exists
    x = 1372398
    y = 62597
    p = lab.actor_to_actor_path(db_large, x, y)
    e = [1372398, 7056, 4566, 540, 100567, 62597]

    check_valid_path(raw_db_large, p, x, y, len(e) - 1)
Beispiel #12
0
def test_actor_to_actor_path_03():
    # Bacon path, large database, length of 7 (8 actors, 7 movies)
    actor_1 = 43011
    actor_2 = 1379833
    len_expected = 7

    result = lab.actor_to_actor_path(db_large, actor_1, actor_2)
    check_valid_path(raw_db_large, result, actor_1, actor_2, len_expected)
Beispiel #13
0
 def test_19(self):
     # actor path that exists
     e = [184581, 27111, 11086, 170882]
     x = e[0]
     y = e[-1]
     p = lab.actor_to_actor_path(self.db_large, x, y)
     self.assertTrue(valid_path(self.db_large, p))
     self.assertEqual(len(p), len(e))
     self.assertEqual(p[0], x)
     self.assertEqual(p[-1], y)
Beispiel #14
0
def test_actor_to_actor_path_07():
    # actor path that exists
    e = list(range(700))
    random.shuffle(e)
    data = [(i, j, 0) for i, j in zip(e, e[1:])]
    random.shuffle(data)
    x = e[0]
    y = e[-1]
    p = lab.actor_to_actor_path(lab.transform_data(data), x, y)
    check_valid_path(data, p, x, y, len(e) - 1)
Beispiel #15
0
 def test_18(self):
     # actor path that exists
     x = 1372398
     y = 62597
     p = lab.actor_to_actor_path(self.db_large, x, y)
     e = [1372398, 7056, 4566, 540, 100567, 62597]
     self.assertTrue(valid_path(self.db_large, p))
     self.assertEqual(len(p), len(e))
     self.assertEqual(p[0], x)
     self.assertEqual(p[-1], y)
Beispiel #16
0
 def test_16(self):
     # Bacon path, large database, length of 7 (8 actors, 7 movies)
     actor_1 = 43011
     actor_2 = 1379833
     len_expected = 7
     result = lab.actor_to_actor_path(self.db_large, actor_1, actor_2)
     len_result = -1 if result is None else len(result) - 1
     self.assertTrue(valid_path(self.db_large, result))
     self.assertEqual(len_result, len_expected)
     self.assertEqual(result[0], actor_1)
     self.assertEqual(result[-1], actor_2)
Beispiel #17
0
 def test_15(self):
     # Actor path, large database, length of 4 (5 actors, 4 movies)
     actor_1 = 100414
     actor_2 = 57082
     len_expected = 4
     result = lab.actor_to_actor_path(self.db_large, actor_1, actor_2)
     len_result = -1 if result is None else len(result) - 1
     self.assertTrue(valid_path(self.db_large, result))
     self.assertEqual(len_result, len_expected)
     self.assertEqual(result[0], actor_1)
     self.assertEqual(result[-1], actor_2)
Beispiel #18
0
def _run_pickled_a2a_path_test(n):
    filename = os.path.join(
        TEST_DIRECTORY,
        'resources',
        'tests',
        'actor_to_actor_path_%02d.pickle' % n,
    )
    with open(filename, 'rb') as f:
        tests = pickle.load(f)
    for a1, a2, l in tests:
        path = lab.actor_to_actor_path(db_large, a1, a2)
        check_valid_path(fset_large, path, a1, a2, l)
Beispiel #19
0
    def test_14(self):
        # Actor path, large database, length of 7 (8 actors, 7 movies)
        actor_1 = 1345462
        actor_2 = 89614
        len_expected = 7

        first_result = lab.actor_to_actor_path(self.db_large, actor_1, actor_2)
        len_first_result = -1 if first_result is None else len(
            first_result) - 1
        self.assertTrue(valid_path(self.db_large, first_result))
        self.assertEqual(len_first_result, len_expected)
        self.assertEqual(first_result[0], actor_1)
        self.assertEqual(first_result[-1], actor_2)

        second_result = lab.actor_to_actor_path(self.db_large, actor_1,
                                                actor_2)
        len_second_result = -1 if second_result is None else len(
            second_result) - 1
        self.assertTrue(valid_path(self.db_large, second_result))
        self.assertEqual(len_second_result, len_expected)
        self.assertEqual(second_result[0], actor_1)
        self.assertEqual(second_result[-1], actor_2)
Beispiel #20
0
 def test_20(self):
     # actor path that exists
     e = list(range(700))
     random.shuffle(e)
     data = [(i, j, 0) for i, j in zip(e, e[1:])]
     random.shuffle(data)
     x = e[0]
     y = e[-1]
     p = lab.actor_to_actor_path(data, x, y)
     self.assertTrue(valid_path(data, p))
     self.assertEqual(len(p), len(e))
     self.assertEqual(p[0], x)
     self.assertEqual(p[-1], y)
Beispiel #21
0
 def test_22(self):
     x = 1279926
     y = 58571
     data = self.db_large[:]
     print(lab.actor_to_actor_path(data, x, y))
Beispiel #22
0
 def test_22(self):
     x = 2876
     y = 74881
     result = lab.actor_to_actor_path(self.data, x, y)
     expected = None
     self.assertEqual(result, expected)
Beispiel #23
0
def test_actor_to_actor_path_custom():
    # Robert Maximillian to Peter Brouwer
    actor_1 = 1395659
    actor_2 = 1081852
    result = lab.actor_to_actor_path(db_large, actor_1, actor_2)
    assert result == [1395659, 1086622, 8635, 83400, 107373, 1081852]
Beispiel #24
0
def test_tiny_actor_to_actor_path():
    # Actor path, large database, length of 7 (8 actors, 7 movies)
    actor_1 = 1640
    actor_2 = 1532
    assert lab.actor_to_actor_path(db_tiny, actor_1,
                                   actor_2) == [1640, 2876, 1532]