Exemplo n.º 1
0
    def test_expected_field_exists_value(self):
        from ddbmock.database.item import Item
        from ddbmock.errors import ConditionalCheckFailedException

        # ok
        item = Item({FIELDNAME: VALUE_S})
        item.assert_match_expected(
            {FIELDNAME: {
                'Exists': True,
                'Value': VALUE_S
            }})

        # exitence mismatch
        item = Item({})
        self.assertRaises(ConditionalCheckFailedException,
                          item.assert_match_expected,
                          {FIELDNAME: {
                              'Exists': True,
                              'Value': VALUE_S
                          }})

        # type mismatch
        item = Item({FIELDNAME: VALUE_S})
        self.assertRaises(ConditionalCheckFailedException,
                          item.assert_match_expected,
                          {FIELDNAME: {
                              'Exists': True,
                              'Value': VALUE_N
                          }})
Exemplo n.º 2
0
    def test_expected_field_does_not_exist(self):
        from ddbmock.database.item import Item
        from ddbmock.errors import ConditionalCheckFailedException

        # ok
        item = Item({})
        item.assert_match_expected({FIELDNAME: {u'Exists': False}})

        # mismatch
        item = Item({FIELDNAME: VALUE_SS})
        self.assertRaises(ConditionalCheckFailedException,
                          item.assert_match_expected,
                          {FIELDNAME: {
                              u'Exists': False
                          }})
Exemplo n.º 3
0
    def test_expected_field_does_not_exist(self):
        from ddbmock.database.item import Item
        from ddbmock.errors import ConditionalCheckFailedException

        # ok
        item = Item({})
        item.assert_match_expected({
           FIELDNAME: {u'Exists': False}
        })

        # mismatch
        item = Item({FIELDNAME: VALUE_SS})
        self.assertRaises(ConditionalCheckFailedException,
                          item.assert_match_expected,
                          {FIELDNAME: {u'Exists': False}})
Exemplo n.º 4
0
    def test_expected_field_exists_value(self):
        from ddbmock.database.item import Item
        from ddbmock.errors import ConditionalCheckFailedException

        # ok
        item = Item({FIELDNAME: VALUE_S})
        item.assert_match_expected({
           FIELDNAME: {'Exists': True, 'Value': VALUE_S}
        })

        # exitence mismatch
        item = Item({})
        self.assertRaises(ConditionalCheckFailedException,
                          item.assert_match_expected,
                          {FIELDNAME: {'Exists': True, 'Value': VALUE_S}})

        # type mismatch
        item = Item({FIELDNAME: VALUE_S})
        self.assertRaises(ConditionalCheckFailedException,
                          item.assert_match_expected,
                          {FIELDNAME: {'Exists': True, 'Value': VALUE_N}})