Skip to content

Commit

Permalink
Adding projects test (#522)
Browse files Browse the repository at this point in the history
* Adding projects test

* adding new test

* addin exceptions test

* lint fix for test
  • Loading branch information
labhvam5 authored Nov 23, 2023
1 parent d4327f7 commit 3d21a48
Show file tree
Hide file tree
Showing 10 changed files with 6,971 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fyle_integrations_imports
109 changes: 105 additions & 4 deletions tests/sql_fixtures/reset_db_fixtures/reset_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--

-- Dumped from database version 15.4 (Debian 15.4-2.pgdg120+1)
-- Dumped by pg_dump version 15.4 (Debian 15.4-2.pgdg100+1)
-- Dumped by pg_dump version 15.4 (Debian 15.4-2.pgdg120+1)

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -1223,6 +1223,48 @@ CREATE TABLE public.general_mappings (

ALTER TABLE public.general_mappings OWNER TO postgres;

--
-- Name: import_logs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.import_logs (
id integer NOT NULL,
attribute_type character varying(150) NOT NULL,
status character varying(255),
error_log jsonb NOT NULL,
total_batches_count integer NOT NULL,
processed_batches_count integer NOT NULL,
last_successful_run_at timestamp with time zone,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
workspace_id integer NOT NULL
);


ALTER TABLE public.import_logs OWNER TO postgres;

--
-- Name: import_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.import_logs_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


ALTER TABLE public.import_logs_id_seq OWNER TO postgres;

--
-- Name: import_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.import_logs_id_seq OWNED BY public.import_logs.id;


--
-- Name: journal_entries; Type: TABLE; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -2179,6 +2221,13 @@ ALTER TABLE ONLY public.fyle_credentials ALTER COLUMN id SET DEFAULT nextval('pu
ALTER TABLE ONLY public.general_mappings ALTER COLUMN id SET DEFAULT nextval('public.mappings_generalmapping_id_seq'::regclass);


--
-- Name: import_logs id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.import_logs ALTER COLUMN id SET DEFAULT nextval('public.import_logs_id_seq'::regclass);


--
-- Name: journal_entries id; Type: DEFAULT; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -2485,6 +2534,10 @@ COPY public.auth_permission (id, name, content_type_id, codename) FROM stdin;
178 Can change expense field 45 change_expensefield
179 Can delete expense field 45 delete_expensefield
180 Can view expense field 45 view_expensefield
181 Can add import log 46 add_importlog
182 Can change import log 46 change_importlog
183 Can delete import log 46 delete_importlog
184 Can view import log 46 view_importlog
\.


Expand Down Expand Up @@ -3733,6 +3786,7 @@ COPY public.django_content_type (id, app_label, model) FROM stdin;
43 workspaces lastexportdetail
44 fyle expensefilter
45 fyle_accounting_mappings expensefield
46 fyle_integrations_imports importlog
\.


Expand Down Expand Up @@ -3912,6 +3966,7 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin;
169 fyle 0032_expense_accounting_export_summary 2023-09-04 09:16:33.110573+00
170 fyle 0033_expense_workspace 2023-09-05 12:23:23.807031+00
171 fyle 0034_expense_previous_export_state 2023-09-07 12:40:23.1024+00
172 fyle_integrations_imports 0001_initial 2023-11-21 17:06:03.547973+00
\.


Expand Down Expand Up @@ -33305,6 +33360,14 @@ COPY public.general_mappings (id, bank_account_name, bank_account_id, default_cc
\.


--
-- Data for Name: import_logs; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.import_logs (id, attribute_type, status, error_log, total_batches_count, processed_batches_count, last_successful_run_at, created_at, updated_at, workspace_id) FROM stdin;
\.


--
-- Data for Name: journal_entries; Type: TABLE DATA; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -33782,7 +33845,7 @@ SELECT pg_catalog.setval('public.auth_group_permissions_id_seq', 1, false);
-- Name: auth_permission_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.auth_permission_id_seq', 180, true);
SELECT pg_catalog.setval('public.auth_permission_id_seq', 184, true);


--
Expand Down Expand Up @@ -33817,14 +33880,14 @@ SELECT pg_catalog.setval('public.django_admin_log_id_seq', 1, false);
-- Name: django_content_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.django_content_type_id_seq', 45, true);
SELECT pg_catalog.setval('public.django_content_type_id_seq', 46, true);


--
-- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.django_migrations_id_seq', 171, true);
SELECT pg_catalog.setval('public.django_migrations_id_seq', 172, true);


--
Expand Down Expand Up @@ -33932,6 +33995,13 @@ SELECT pg_catalog.setval('public.fyle_expensegroupsettings_id_seq', 5, true);
SELECT pg_catalog.setval('public.fyle_rest_auth_authtokens_id_seq', 1, true);


--
-- Name: import_logs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.import_logs_id_seq', 1, false);


--
-- Name: last_export_details_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -34407,6 +34477,22 @@ ALTER TABLE ONLY public.auth_tokens
ADD CONSTRAINT fyle_rest_auth_authtokens_user_id_3b4bd82e_uniq UNIQUE (user_id);


--
-- Name: import_logs import_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.import_logs
ADD CONSTRAINT import_logs_pkey PRIMARY KEY (id);


--
-- Name: import_logs import_logs_workspace_id_attribute_type_42f69b7b_uniq; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.import_logs
ADD CONSTRAINT import_logs_workspace_id_attribute_type_42f69b7b_uniq UNIQUE (workspace_id, attribute_type);


--
-- Name: last_export_details last_export_details_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -34974,6 +35060,13 @@ CREATE INDEX fyle_expensegroup_expenses_expensegroup_id_1af76dce ON public.expen
CREATE INDEX fyle_expensegroup_workspace_id_c9b3a8e4 ON public.expense_groups USING btree (workspace_id);


--
-- Name: import_logs_workspace_id_e5acf2ff; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX import_logs_workspace_id_e5acf2ff ON public.import_logs USING btree (workspace_id);


--
-- Name: mapping_settings_expense_field_id_e9afc6c2; Type: INDEX; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -35363,6 +35456,14 @@ ALTER TABLE ONLY public.general_mappings
ADD CONSTRAINT general_mappings_workspace_id_19666c5c_fk_workspaces_id FOREIGN KEY (workspace_id) REFERENCES public.workspaces(id) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: import_logs import_logs_workspace_id_e5acf2ff_fk_workspaces_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.import_logs
ADD CONSTRAINT import_logs_workspace_id_e5acf2ff_fk_workspaces_id FOREIGN KEY (workspace_id) REFERENCES public.workspaces(id) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: last_export_details last_export_details_workspace_id_0af72f0e_fk_workspaces_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
Expand Down
36 changes: 36 additions & 0 deletions tests/test_fyle_integrations_imports/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from fyle_integrations_imports.modules.base import Base
from fyle_integrations_platform_connector import PlatformConnector
from apps.workspaces.models import FyleCredential, QBOCredential
from apps.quickbooks_online.utils import QBOConnector


def get_base_class_instance(
workspace_id: int = 1,
source_field: str = 'PROJECT',
destination_field: str = 'PROJECT',
platform_class_name: str = 'projects',
sync_after: str = None,
destination_sync_method: str = 'customers'
):

qbo_credentials = QBOCredential.get_active_qbo_credentials(workspace_id)
qbo_connection = QBOConnector(credentials_object=qbo_credentials, workspace_id=workspace_id)

base = Base(
workspace_id = workspace_id,
source_field = source_field,
destination_field = destination_field,
platform_class_name = platform_class_name,
sync_after = sync_after,
sdk_connection = qbo_connection,
destination_sync_method = destination_sync_method
)

return base


def get_platform_connection(workspace_id):
fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id)
platform = PlatformConnector(fyle_credentials=fyle_credentials)

return platform
Loading

0 comments on commit 3d21a48

Please sign in to comment.