Beispiel #1
0
def test_store_retrieve_team(ddb):
    """Test to see if we can store and retrieve the same team."""
    team = create_test_team('1', 'rocket2.0', 'Rocket 2.0')
    assert ddb.store(team)
    another_team = ddb.retrieve(Team, '1')

    assert team == another_team
Beispiel #2
0
    def test_delete_team(self):
        team = create_test_team('1', 'rocket-2.0', 'Rocket 2.0')
        self.assertTrue(self.ddb.store(team))

        self.assertEqual(len(self.ddb.query(Team)), 1)
        self.ddb.delete(Team, '1')
        self.assertEqual(len(self.ddb.query(Team)), 0)
Beispiel #3
0
    def test_store_retrieve_team(self):
        """Test to see if we can store and retrieve the same team."""
        team = create_test_team('1', 'rocket2.0', 'Rocket 2.0')
        self.assertTrue(self.ddb.store(team))
        another_team = self.ddb.retrieve(Team, '1')

        self.assertEqual(team, another_team)
Beispiel #4
0
def test_delete_team(ddb):
    """Test to see if we can successfully delete a team."""
    team = create_test_team('1', 'rocket-2.0', 'Rocket 2.0')
    ddb.store(team)

    assert len(ddb.query(Team)) == 1
    ddb.delete(Team, '1')
    assert len(ddb.query(Team)) == 0
Beispiel #5
0
 def test_query_or_teams(self):
     """Test edge cases like set inclusion in query_or."""
     teams = [create_test_team(str(i), "glob", "name") for i in range(10)]
     member_to_check = list(teams[0].members)[0]
     param = [('members', member_to_check)]
     for team in teams:
         self.assertTrue(self.ddb.store(team))
     queried_teams = self.ddb.query_or(Team, param)
     for team in teams:
         self.assertIn(team, queried_teams)
Beispiel #6
0
def test_query_team(ddb):
    """Test to see if we can store and query the same team."""
    team = create_test_team('1', 'rocket2.0', 'Rocket 2.0')
    team2 = create_test_team('2', 'lame-o', 'Lame-O Team')
    team2.add_member('apple')
    ddb.store(team)
    ddb.store(team2)

    another_team = ddb.query(Team, [('display_name', 'Rocket 2.0')])
    same_team = ddb.query(Team, [('platform', 'slack')])
    multiple_queries = ddb.query(Team, [('display_name', 'Rocket 2.0'),
                                        ('platform', 'slack')])
    member_team = ddb.query(Team, [('members', 'abc_123'),
                                   ('members', 'apple')])
    all_team = ddb.query(Team)

    assert team == another_team[0]
    assert team == all_team[0]
    assert team == same_team[0]
    assert team == multiple_queries[0]
    assert team2 == member_team[0]
Beispiel #7
0
    def test_query_team(self):
        """Test to see if we can store and query the same team."""
        team = create_test_team('1', 'rocket2.0', 'Rocket 2.0')
        team2 = create_test_team('2', 'lame-o', 'Lame-O Team')
        team2.add_member('apple')
        self.assertTrue(self.ddb.store(team))
        self.assertTrue(self.ddb.store(team2))

        another_team = self.ddb.query(Team, [('displayname', 'Rocket 2.0')])
        same_team = self.ddb.query(Team, [('platform', 'slack')])
        multi_queries = self.ddb.query(Team, [('displayname', 'Rocket 2.0'),
                                              ('platform', 'slack')])
        member_team = self.ddb.query(Team, [('members', 'abc_123'),
                                            ('members', 'apple')])
        all_team = self.ddb.query(Team)

        self.assertEqual(team, another_team[0])
        self.assertEqual(team, all_team[0])
        self.assertEqual(team, same_team[0])
        self.assertEqual(team, multi_queries[0])
        self.assertEqual(team2, member_team[0])
Beispiel #8
0
def test_valid_team():
    """Test the Team static class method is_valid()."""
    team = Team("1", "", "Brussel Sprouts")
    assert not Team.is_valid(team)
    team = create_test_team("1", "brussel-sprouts", "Brussel Sprouts")
    assert Team.is_valid(team)
Beispiel #9
0
def test_store_team(ddb):
    """Test storing team calls correct functions."""
    dbf = DBFacade(ddb)
    test_team = create_test_team('1', 'brussel-sprouts', 'Brussel Sprouts')
    dbf.store(test_team)
    ddb.store.assert_called_with(test_team)