Ejemplo n.º 1
0
    def test_createWalletPlanningForm(self):
        walletForm = forms.createWalletPlanningForm(
            pd.DataFrame(
                {
                    'Ticker': ['A', 'B'],
                    'Quantidade': [0, 0],
                    'Porcentagem alvo': [50, 50],
                }, ), )

        fieldList = ['ticker', 'quantity', 'percent']
        formFieldList = []
        for form in walletForm.forms:
            formFieldList += list(form.base_fields.keys())

        self.assertTrue(set(fieldList) == set(formFieldList))
Ejemplo n.º 2
0
 def test_createWalletPlanningFormFailurePercentBelowNotFilled(self):
     walletForm = forms.createWalletPlanningForm()
     data = {
         'capital': 100,
         'form-TOTAL_FORMS': '2',
         'form-INITIAL_FORMS': '2',
         'form-MIN_NUM_FORMS': '0',
         'form-MAX_NUM_FORMS': '1000',
         'form-0-ticker': self.stock1,
         'form-0-quantity': '2',
         'form-1-ticker': self.stock2,
         'form-1-quantity': '2',
         'form-1-percent': '-50',
     }
     form = walletForm(data)
     self.assertFalse(form.is_valid())
Ejemplo n.º 3
0
 def test_createWalletPlanningFormFailureManagement(self):
     walletForm = forms.createWalletPlanningForm()
     data = {
         'capital': 100,
         'form-INITIAL_FORMS': '2',
         'form-MIN_NUM_FORMS': '0',
         'form-MAX_NUM_FORMS': '1000',
         'form-0-ticker': self.stock1,
         'form-0-quantity': '2',
         'form-0-percent': '50',
         'form-1-ticker': self.stock2,
         'form-1-quantity': '2',
         'form-1-percent': '50',
     }
     form = walletForm(data)
     self.assertRaises(ValidationError, form.is_valid)
Ejemplo n.º 4
0
 def test_createWalletPlanningFormFailurePercentFill(self):
     walletForm = forms.createWalletPlanningForm()
     data = {
         'capital': 100,
         'form-TOTAL_FORMS': '2',
         'form-INITIAL_FORMS': '2',
         'form-MIN_NUM_FORMS': '0',
         'form-MAX_NUM_FORMS': '1000',
         'form-0-ticker': self.stock1,
         'form-0-quantity': '2',
         'form-0-percent': '50',
         'form-1-ticker': self.stock2,
         'form-1-quantity': '2',
     }
     form = walletForm(data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_data[1]['percent'], 50)
Ejemplo n.º 5
0
 def test_createWalletPlanningFormCleanFailureCapital(self):
     walletForm = forms.createWalletPlanningForm()
     data = {
         'capital': 0,
         'form-TOTAL_FORMS': '2',
         'form-INITIAL_FORMS': '2',
         'form-MIN_NUM_FORMS': '0',
         'form-MAX_NUM_FORMS': '1000',
         'form-0-ticker': self.stock1,
         'form-0-quantity': '2',
         'form-0-percent': '50',
         'form-1-ticker': self.stock1,
         'form-1-quantity': '2',
         'form-1-percent': '50',
     }
     form = forms.CapitalForm(data)
     self.assertFalse(form.is_valid())