예제 #1
0
    def test_all_payment_search(self):
        created_payments = [
            PagSegPayment(status=STATUS_CREATED) for i in xrange(3)
        ]
        ndb.put_multi(created_payments)
        # reversing because search is desc
        created_payments.reverse()

        sent_payments = [
            PagSegPayment(status=STATUS_SENT_TO_PAGSEGURO) for i in xrange(3)
        ]
        ndb.put_multi(sent_payments)
        sent_payments.reverse()
        # Testing search for all
        cmd = pagseguro_facade.search_all_payments(page_size=3).execute()
        self.assertListEqual(sent_payments, cmd.result)
        cmd2 = pagseguro_facade.search_all_payments(
            page_size=3, start_cursor=cmd.cursor).execute()
        self.assertListEqual(created_payments, cmd2.result)
        cmd3 = pagseguro_facade.search_all_payments(
            page_size=3, start_cursor=cmd2.cursor).execute()
        self.assertListEqual([], cmd3.result)

        # Test search based on status
        cmd = pagseguro_facade.search_all_payments(STATUS_SENT_TO_PAGSEGURO,
                                                   page_size=4).execute()
        self.assertListEqual(sent_payments, cmd.result)
        cmd = pagseguro_facade.search_all_payments(STATUS_CREATED,
                                                   page_size=4).execute()
        self.assertListEqual(created_payments, cmd.result)
예제 #2
0
 def test_user_arc_creation(self):
     # Payment creation
     user = mommy.save_one(MainUser, email='*****@*****.**')
     cmd = pagseguro_facade.procces_external_payment_cmd(generate_xml('non particular id', '1', '18.99'))
     cmd()
     payments = pagseguro_facade.search_all_payments(relations=['owner'])()
     self.assertEqual(1, len(payments))
     self.assertEqual(user, payments[0].owner)
예제 #3
0
 def test_user_arc_creation(self):
     # Payment creation
     user = mommy.save_one(MainUser, email='*****@*****.**')
     cmd = pagseguro_facade.procces_external_payment_cmd(
         generate_xml('non particular id', '1', '18.99'))
     cmd()
     payments = pagseguro_facade.search_all_payments(relations=['owner'])()
     self.assertEqual(1, len(payments))
     self.assertEqual(user, payments[0].owner)
예제 #4
0
 def test_user_creation(self):
     # Payment creation
     cmd = pagseguro_facade.procces_external_payment_cmd(generate_xml('non particular id', '1', '18.99'))
     cmd()
     payments = pagseguro_facade.search_all_payments(relations=['owner'])()
     self.assertEqual(1, len(payments))
     self.assertIsInstance(payments[0].owner, MainUser)
     self.assertEqual('*****@*****.**', payments[0].owner.email)
     self.assertEqual('José Comprador', payments[0].owner.name)
예제 #5
0
 def test_user_creation(self):
     # Payment creation
     cmd = pagseguro_facade.procces_external_payment_cmd(
         generate_xml('non particular id', '1', '18.99'))
     cmd()
     payments = pagseguro_facade.search_all_payments(relations=['owner'])()
     self.assertEqual(1, len(payments))
     self.assertIsInstance(payments[0].owner, MainUser)
     self.assertEqual('*****@*****.**', payments[0].owner.email)
     self.assertEqual('José Comprador', payments[0].owner.name)
예제 #6
0
    def test_all_payment_search(self):
        created_payments = [PagSegPayment(status=STATUS_CREATED) for i in xrange(3)]
        ndb.put_multi(created_payments)
        # reversing because search is desc
        created_payments.reverse()

        sent_payments = [PagSegPayment(status=STATUS_SENT_TO_PAGSEGURO) for i in xrange(3)]
        ndb.put_multi(sent_payments)
        sent_payments.reverse()
        # Testing search for all
        cmd = pagseguro_facade.search_all_payments(page_size=3).execute()
        self.assertListEqual(sent_payments, cmd.result)
        cmd2 = pagseguro_facade.search_all_payments(page_size=3, start_cursor=cmd.cursor).execute()
        self.assertListEqual(created_payments, cmd2.result)
        cmd3 = pagseguro_facade.search_all_payments(page_size=3, start_cursor=cmd2.cursor).execute()
        self.assertListEqual([], cmd3.result)

        # Test search based on status
        cmd = pagseguro_facade.search_all_payments(STATUS_SENT_TO_PAGSEGURO, page_size=4).execute()
        self.assertListEqual(sent_payments, cmd.result)
        cmd = pagseguro_facade.search_all_payments(STATUS_CREATED, page_size=4).execute()
        self.assertListEqual(created_payments, cmd.result)