Exemplo n.º 1
0
def rebase_customer(body):
    customer = json.loads(body.decode())
    new_customer = Customer.create(id=customer['id'], name=customer['name'])
    new_customer.save(force_insert=True)
Exemplo n.º 2
0
class TestClassCustomer:
    def setup(self):
        self.new_customer = Customer()

    def test_customer_email(self):
        self.new_customer.set_email("*****@*****.**")
        assert self.new_customer.get_email() == "*****@*****.**"

    def test_customer_email_negative(self):
        try:
            self.new_customer.get_email()
            assert False
        except Exception:
            assert True

    def test_customer_set_email(self):
        assert self.new_customer.set_email("*****@*****.**") == None

    def test_customer_set_email_negative(self):
        try:
            self.new_customer.set_email("*****@*****.**")
            assert False
        except EmailException as e:
            assert e.message == "Email format invalid"

    def test_customer_name(self):
        self.new_customer.set_name("ravinder")
        assert self.new_customer.get_name() == "ravinder"

    def test_customer_name_negative(self):
        try:
            self.new_customer.get_name()
            assert False
        except Exception:
            assert True

    def test_customer_set_name(self):
        assert self.new_customer.set_name("ravinder") == None

    def test_customer_set_email_name(self):
        try:
            self.new_customer.set_name("rdasda12323")
            assert False
        except NameException as e:
            assert e.message == "Name format invalid"

    def test_customer_create(self):
        self.new_customer.create("ravinder", "*****@*****.**")
        assert self.new_customer.get_name() == "ravinder"
        assert self.new_customer.get_email() == "*****@*****.**"

    def test_customer_create_negative(self):
        try:
            self.new_customer.create("ravinasdasd12213123der",
                                     "*****@*****.**")
            assert False
        except NameException as e:
            assert e.message == "Name format invalid"
        try:
            self.new_customer.create("ravinder", "*****@*****.**")
        except EmailException as e:
            assert e.message == "Email format invalid"
Exemplo n.º 3
0
# delete 2nd seller
#print(sellers.fetch_all())
#sellers.delete('2nd seller')
#print(sellers.fetch_all())

# publish feeds
sellers.publish('3rd seller', '1st product', 150)
sellers.publish('1st seller', '2nd product', 200)
sellers.publish('1st seller', '4th product', 250)
sellers.publish('1st seller', '3rd product', 350)
sellers.publish('3rd seller', '5rd product', 5000)
sellers.publish('2nd seller', '6th product', 5555)

# create customers
customers.create('1st customer')
customers.create('2nd customer')
#customers.create('3rd customer')

customers.subscribe('1st customer', '1st seller')
customers.subscribe('1st customer', '2nd seller')
customers.subscribe('1st customer', '3rd seller')

#print(customers.fetch_feeds('1st customer'))
#sellers.delete_post('2nd seller', '6th product')
print(customers.fetch_feeds('1st customer'))
print(customers.fetch_feeds('1st customer', 'seller_rating'))

#print(customers.fetch_all())
# print(customers.fetch_feeds('1st customer', 'time'))